#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Defines instanceconfig component that decorates request environments.


"""

## TODO: grow a nice function for gathering the config from (1) the
## library, (2) the installed modules and (3) the instance .


def instanceconfig(app, config, key='config'):
    """

    @param config any object
    @param key='config' key for config object
    """
    def configurator(environ, start_response):
        if key not in environ:
            environ[key] = config
        return app(environ, start_response)
    return configurator
